<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
	function onLoadControl(){
	   var nowTime = new Date();
	   document.getElementsByName("qaNew.limit_date_year")[0].value = nowTime.getYear();   
	   var limit_date_month = nowTime.getMonth();
	   var limit_date_day = nowTime.getDate();
	   limit_date_month++;
	   if(limit_date_month < 10){	  
	   		limit_date_month = "0"+limit_date_month;
	   }
	    document.getElementsByName("qaNew.limit_date_month")[0].value = limit_date_month;	   
	    if(limit_date_day < 10){	  
	   		limit_date_day = "0"+limit_date_day;
	   }
	    document.getElementsByName("qaNew.limit_date_day")[0].value = limit_date_day;
	}

	function doCheck(form){
		    var sub_system = document.getElementsByName("qaNew.projectId")[0].value;//プロジェクト
		    var kiNo = document.getElementsByName("qaNew.tema")[0].value; //テーマ名
		    var level = document.getElementsByName("qaNew.level")[0].value; //段階
           var part = document.getElementsByName("qaNew.part")[0].value; //　箇所
           var limit_date_year = document.getElementsByName("qaNew.limit_date_year")[0].value;//limit_date_year
			var limit_date_month = document.getElementsByName("qaNew.limit_date_month")[0].value;	//limit_date_month
			var limit_date_day = document.getElementsByName("qaNew.limit_date_day")[0].value;	//limit_date_day
			var kinkyuu= document.getElementsByName("qaNew.kinkyuu")[0].value; //緊急度
			var asked= document.getElementsByName("qaNew.asked")[0].value;//ASKER	
            var summary = document.getElementsByName("qaNew.summary")[0].value; //SUMMARY      			
			var question = document.getElementsByName("qaNew.question")[0].value;	//question
			var check=/^[1-2]\d{3}$/;
					
			if (level == "") {
				alert("段階を入力して下さい");
				return false;
			}
			if (sub_system == "") {
				alert("ｻﾌﾞｼｽﾃﾑを入力して下さい");
				return false;
			}
			if (part == "") {
				alert("発生箇所を入力して下さい");
				return false;
			}
			if (kiNo == "") {
				alert("機能を入力して下さい");
				return false;
			}
			if (limit_date_year == "") {
			    alert("回答期限_年を入力して下さい");
			    return false;
			}
		
			if (!check.test(limit_date_year)){
			    alert("正しい回答期限_年を入力下さい");
			    return false;
			}
			if (limit_date_month == "") {
				alert("回答期限_月を入力して下さい");
				return false;
			}
			if (limit_date_day == "") {
				alert("回答期限_日を入力して下さい");
				return false;
			}
			var nowTime = new Date();		
			nowYear = nowTime.getYear();		
			if (( limit_date_month == 4 || limit_date_month == 6 || limit_date_month == 9 || limit_date_month == 11) && limit_date_day == 31) {
				alert("回答期限には実在する日付を入力して下さい");
				return false;
			}
			if (limit_date_month == 2) {
				if (limit_date_year%4 == 0 && limit_date_day > 29) {
					alert("回答期限には実在する日付を入力して下さい");
					return false;
				}
				if (limit_date_year%4 !=0 && limit_date_day > 28) {
					alert("回答期限には実在する日付を入力して下さい");
					return false;
				}
			}
			var d1 = nowTime.getYear()+"/"+ (nowTime.getMonth()+1) +"/"+nowTime.getDate();
			var d2 = limit_date_year+ "/" + limit_date_month +"/"+ limit_date_day;
            if ( (Date.parse(d1) - Date.parse(d2)) > 0){
                alert("回答期限が、提出日付より過去日付になっているので修正して下さい");
                return false;              
            } 			
			if (kinkyuu == "") {
				alert("緊急度を入力して下さい");
			    return false;
			}
			if (asked == "") {
				alert("問合先を入力して下さい");
				return false;
			}
			if (summary == "") {
				alert("質問概要を入力して下さい");
				return false;
			}
			if (question == "") {
				alert("質問詳細を入力して下さい");
				return false;
			}						
					 						
 			document.newForm.submit();
		}
   </script> 
   <style type="text/css">
      body {
         font-family: Arial, Helvetica, sans-serif;
         font-size:12px;
      }
      fieldset {
         padding:10px;
         margin-top:5px;
         border:1px solid #A4CDF2;
         font-size:12px;
        }
      fieldset legend {
         font-weight:bold;
         font-size: 15px;          
       }
      div_footer{
        text-align:center;
        font-size:12px;
      }
      .textfield{
         width:40px;
         color:#003366; 
         font-size:12px;
      }
      .textarea{
        color:#003366;
        font-size:12px;
      }
     .btn_1{   
       BORDER-RIGHT:#002D96 1px solid;   
       PADDING-RIGHT:2px;   BORDER-TOP:#002D96 1px solid;   
       PADDING-LEFT:2px;   
       FONT-SIZE:12px;
       FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#FFFFFF,EndColorStr=#9DBCEA);   
       BORDER-LEFT:   #002D96   1px   solid;   
       CURSOR:hand;   
       COLOR: black;   
       PADDING-TOP:2px;   
       BORDER-BOTTOM:#002D96 1px solid;
       font-size:12px; 
    }
    .select{
      width:130px;
      border-right: #000000 1px solid;
      border-top: #ffffff 1px solid;
      border-left: #ffffff 1px solid;
      color:#003366;
      border-bottom: #000000 1px solid;
      background-color: #f4f4f4;
      font-size:12px;
    }
    .select_m{
      border-right: #000000 1px solid;
      border-top: #ffffff 1px solid;
      border-left: #ffffff 1px solid;
      color:#003366;
      border-bottom: #000000 1px solid;
      background-color: #f4f4f4;
      font-size:12px;
    }
 </style>
<title>新規QA</title>
</head>
<body text=#003366 onLoad="onLoadControl()">
<s:form method='POST' enctype='multipart/form-data' name="newForm">
<fieldset>
<legend>新規QA</legend>
<table width=70% align="center">
	<tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% height=25 style="font-size:12px;">プロジェクト</td>
              <td align="left" height=25>
              <s:select theme="simple" cssClass="select" id="projectId" name="qaNew.projectId" headerKey="" headerValue="" list="projectList" listKey="projectId" listValue="projectName" value="" />
              	</td>
          </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% height=25 bgcolor=RGB(221,230,247) style="font-size:12px;">テーマ名</td>
              <td align="left" height=25>
              <s:select theme="simple" cssClass="select" id="tema" name="qaNew.tema" headerKey="" headerValue="" list="functionArray" listKey="theme_id" listValue="theme_name" value="" />
			</td>
         </tr>
         </table>
    </td>
    </tr>    
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>              
              <td width=30% height=25 style="font-size:12px;">段階</td>
              <td align="left" height=25>
       <s:select  name="qaNew.level" headerKey="" headerValue="" list="levelArray" listKey="master_value" 
                  listValue="master_value" theme = "simple" value="qaNew.level"
                  cssClass="select" />
			    </td>
         </tr>
         </table>
    </td>
    </tr> 
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% height=25 style="font-size:12px;">発生箇所</td>
              <td align="left" height=25>
        <s:select  name="qaNew.part" headerKey="" headerValue="" list="partArray" listKey="master_value" 
                listValue="master_value" theme = "simple" cssClass="select" value="qaNew.part" />				
					</td>
         </tr>
         </table>
    </td>
    </tr>
    
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% height=25 style="font-size:12px;">回答期限</td>
              <td align="left" height=25 style="font-size:12px;">
      <s:textfield name ="qaNew.limit_date_year" labelposition = "right" theme = "simple" cssClass= "textfield" maxlength="4"/>年
      <s:select  name="qaNew.limit_date_month" theme ="simple" headerKey="" headerValue="" 
      list="monthArray"  cssClass="select_m"
      />月
	  <s:select  name="qaNew.limit_date_day" theme ="simple" headerKey="" headerValue="" list="dayArray"  
	  required="true" cssClass="select_m"/>日
	   </td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% height=25 style="font-size:12px;">緊急度</td>
              <td align="left" height=25>
       <s:select name="qaNew.kinkyuu" theme ="simple" headerKey="" headerValue="" list="kinkyuuArray" 
       listKey="master_value" listValue="master_value" value="qaNew.kinkyuu" cssClass="select"/> 
                </td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% height=25 style="font-size:12px;">問合先</td>
              <td align="left" height=25>
              <s:select id="asked" name="qaNew.asked" theme ="simple" headerKey="" headerValue="" 
     list="askedArray" listKey="user_disp_value" listValue="user_disp_value" 
     value="qaNew.asked" cssClass="select"/> 
            </td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">質問概要</td>
              <td align="left">
					<textarea rows=4 cols=50 name="qaNew.summary" class="textarea"></textarea></td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">質問詳細</td>
              <td align="left">
					<textarea rows=7 cols=50 name="qaNew.question" class="textarea"></textarea></td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247) style="font-size:12px;">
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">備考</td>
              <td align="left">
					<textarea rows=4 cols=50 name="qaNew.memo" class="textarea"></textarea></td>
         </tr>
         </table>
    </td>
    </tr><!--SQLite JDBC Driver has't supported BLOB type yet.So disabled the upload function.
    <tr>
    <td bgcolor=RGB(221,230,247) style="font-size:12px;">
         <table width=100%>
              <tr>
              <td width=30% style="font-size:12px;">添付資料</td>
              <td align=left width=70%>
              <input type="file" name ="myFile" theme = "simple" labelposition = "right" oncontextmenu="window.event.returnValue=false;" onkeydown="return false;" />
              </td>
              </tr>
         </table>
    </td>
    </tr>-->
    </table>

</fieldset>
	<table cellpadding="0" cellspacing="0" width="100%" bgcolor=RGB(238,242,251)>
		<tr>
		　<td align = "left" width="40%">
		　<s:submit btnId="C014" action="qaAllList" value="戻    　る" theme = "simple" cssClass="btn_1"/>
		 </td>  
		 <td align = "left" width="40%">  
		 <s:submit btnId="C015" action="qaAdd" value="追 加/完 了" theme = "simple" cssClass="btn_1" onclick="return doCheck(newForm)"/>
		 </td>
		 <td width="20%">				
        <s:submit btnId="C016" action="qaInsert"  theme = "simple" value = "完      了" cssClass="btn_1" onclick="return doCheck(newForm)" />                  
         </td>       
		</tr>
	</table>
</s:form>
</body>
</html>